package apiday06.homework.thread;

public class Bank {

    public synchronized boolean getMoney(int money){
        int account = getAccount();
        if (account>=money){
            account-=money;
            Thread.yield();
            saveAccount(account);
            return true;
        }
        return false;
    }

    private int account = 20000;

    public int getAccount() {
        return account;
    }

    public void saveAccount(int account) {
        this.account = account;
    }
}
